#ifndef __UGEN_BUSINESS_H__
#define __UGEN_BUSINESS_H__
#include "ugen_feature.h"
#include "ugen_main.h"

#define RECV_UART_DATA_MAXLENGTH 80 //mcu上报下发指令最大长度
#define UART_DATA_LEN 32            //数据包长度
#define MCU_CMD_HEAD 0xD1           //MCU数据包头
#define MODEL_CMD_HEAD 0xD0         //模组数据包头

extern unsigned char FACTORY_TEST_FLAG;

typedef struct
{
    uint8_t head;
    uint8_t check_code;
    uint8_t msg_len;
    uint8_t type;
    uint8_t *cmd_msg;
} DeviceCMD_t;

typedef enum
{
    NETWORK = 0x01,           //配网
    GET_STATE = 0x02,         //MCU查询模组状态
    REPLAY_STATE = 0x03,      //回复MCU查询模组状态
    RESET = 0x04,             //初始化
    HEARTBEAT = 0x05,         //心跳
    UPGRAND_TIME = 0x06,      //时间校准
    FACTORY = 0x07,           //产测
    CHECK_OTA = 0x08,         //模组ota
    UPGRAND_MCU_STATE = 0x10, //设备状态查询
    SETPROPRETY = 0x11,       //下发属性
    UPPROPRETY = 0x12,        //上报属性
    UPEVENT = 0x13            //上报事件
} ugen_currency_cmd;

#ifdef __BUSINESS_CODE_SUPPORT__
typedef struct
{
    char *name;
    uint16_t data;
    uint8_t value;
} ugen_config;

/* 上报的数据的类型 */
typedef enum
{
    TYPE_BOOL = 1,

    TYPE_UINT8_T,
    TYPE_UINT16_T,
    TYPE_UINT32_T,

    TYPE_INT8_T = 5,
    TYPE_INT16_T,
    TYPE_INT32_T,

    TYPE_STRING,

    TYPE_EVENT
    //TYPE_INT64_T
    //TYPE_EVENT = NULL

} ugen_up_cmd_type;

ugen_config *get_ugen_config(void);
void set_property_reply(uint8_t *data, uint32_t len);
void get_ugen_config_value(uint8_t *data, uint8_t len);
void ugen_analysis_cloude_cmd(uint8_t *data, uint8_t len);
#endif //__BUSINESS_CODE_SUPPORT__

void ugen_uart_recv_handle(uint8_t *data, uint32_t len);

#endif //__UGEN_BUSINESS_H__